constraint-editor: Fix saving of constraints
authorMatthias Clasen <mclasen@redhat.com>
Wed, 18 Nov 2020 04:14:29 +0000 (23:14 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 18 Nov 2020 04:14:29 +0000 (23:14 -0500)
g_file_replace_contents take a gsize, so passing -1
for string length does not work here.

demos/constraint-editor/constraint-editor-window.c

index ba25a806ec29e90fe9a21734295e8224141b860f..2ec0f4cd6781f30d48330d3ef3da82892d203e10 100644 (file)
@@ -300,7 +300,7 @@ save_response_cb (GtkNativeDialog        *dialog,
       model = constraint_view_get_model (CONSTRAINT_VIEW (self->view));
       text = serialize_model (model);
       file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
-      g_file_replace_contents (file, text, -1,
+      g_file_replace_contents (file, text, strlen (text),
                                NULL, FALSE,
                                G_FILE_CREATE_NONE,
                                NULL,